package pers.wensheng.patterns.creator_pattern.factory_pattern.simple_factory_pattern.factory;

import pers.wensheng.patterns.creator_pattern.factory_pattern.simple_factory_pattern.entity.AmericanCoffee;
import pers.wensheng.patterns.creator_pattern.factory_pattern.simple_factory_pattern.entity.Coffee;
import pers.wensheng.patterns.creator_pattern.factory_pattern.simple_factory_pattern.entity.LatteCoffee;

/**
 *  简单工厂模式
 *  简单工厂模式与静态工厂模式一样，都违背了开闭原则，要想增加商品都要修改工厂对象里面的代码
 */
public class SimpleCoffeeFactory {
    public Coffee createCoffee(String type){
        Coffee coffee= null;
        if ("americano".equals(type)){
            coffee = new AmericanCoffee();
        } else if ("latte".equals(type)) {
            coffee = new LatteCoffee();
        }
        return coffee;
    }
}
